#ifndef UTILS_H
#define UTILS_H

#include <iostream>
#include <string>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <opencv2/opencv.hpp>

#include <sstream>
#include <iomanip>
#include <ctime>
#include <chrono>

void StringToFloat1024v1(std::string str, float *feature);
void StringToFloat1024v2(std::string str, float *feature);
std::string Float1024ToString(float *feature);

//Utils
boost::property_tree::ptree string2json(std::string json);
std::string json2string(boost::property_tree::ptree tree);
void replaceAll(std::string& base, std::string src, std::string dst);

//Base64-Mat
std::string Mat2Base64(const cv::Mat &img, std::string imgType);
cv::Mat Base2Mat(std::string &base64_data);

//OpenCV Extends
cv::Mat estimateRigidTransform_l(cv::InputArray src1, cv::InputArray src2, bool fullAffine);
float feature_cmp1024(float *feats_src, float *feats_dst, cv::Mat feature_meanval);


//IniParser
class IniParser {
public:
  IniParser(char* filename = "properties.ini");
  ~IniParser();
  int GetInt(char* key, char* session);
  void PutInt(char* key, int val, char* session);
  std::string GetString(char* key, char* session);
  void PutString(char* key, const char* val, char* session);
  float GetFloat(char* key, char* session);
  void PutFloat(char* key, float val, char* session);
private:
  boost::property_tree::ptree lvptProperties;
  char* filename = "properties.ini";
};

#endif //UTILS_H

